<template>
  <div class="container" id="stu-que-bank-management">
    <table-filter>
      <school-dept-class-selection
          show-school
          show-dept
          show-class
          :school-code.sync="apiSetting.data.schoolCode"
          :dept-code.sync="apiSetting.data.deptCode"
          :class-code.sync="apiSetting.data.classCode">
      </school-dept-class-selection>
      <el-input
          placeholder="请输入学生姓名"
          label="学生姓名"
          clearable
          v-model="apiSetting.data.stuName"
      >
      </el-input>
      <el-button plain type="warning" @click="search">查询</el-button>
    </table-filter>
    <el-row>
      <el-button plain type="primary" @click="showEaDialog = true"
      >批量设置
      </el-button
      >
    </el-row>
    <data-table ref="dtb" pagination :api-setting="apiSetting">
      <!--<el-table-column fixed prop="userid" label="UserId" width="100" />-->
      <el-table-column
          prop="usercode"
          label="帐号"
          width="150"
          show-overflow-tooltip
      />
      <el-table-column
          prop="username"
          label="姓名"
          width="175"
          show-overflow-tooltip
      />
      <el-table-column
          prop="schoolname"
          label="学校"
          width="260"
          show-overflow-tooltip
      />
      <el-table-column
          prop="deptname"
          label="院系"
          width="260"
          show-overflow-tooltip
      />
      <el-table-column prop="classname" label="班级" width="260"/>
      <el-table-column label="创建时间" width="215" show-overflow-tooltip>
        <template slot-scope="{ row }">
          {{ row.createtime | formatterDate }}
        </template>
      </el-table-column>
      <el-table-column prop="createperson" label="创建人" width="140"/>
      <el-table-column fixed="right" label="操作">
        <template slot-scope="scope">
          <el-button @click="edit(scope)" type="text" size="small"
          >设置
          </el-button>
        </template>
      </el-table-column>
    </data-table>
    <ea-stu-que-bank ref="eaDialog" :show.sync="showEaDialog"></ea-stu-que-bank>
  </div>
</template>

<script>
import dtb from "@/mixins/refs/dtb";
import EaStuQueBank from "./EaStuQueBank";
import eaDialog from "@/mixins/refs/eaDialog";
import tbSearch from "@/mixins/dataTable/tbSearch";
import SchoolDeptClassSelection from "@/views/component/SchoolDeptClassSelection"

export default {
  name: "index",
  components: {SchoolDeptClassSelection, EaStuQueBank},
  mixins: [tbSearch, dtb, eaDialog],
  data() {
    return {
      apiSetting: {
        method: "post",
        url: "/sys/stuQueBank/getStuList",
        data: {
          stuName: "",
          classCode: "",
          deptCode: "",
          schoolCode: ""
        }
      }
    };
  },
  methods: {
   edit({row}) {
      this.axios
          .get(`/sys/stuQueBank/getUserBank`, {
            params: {
              userid: row.userid
            }
          })
          .then(res => {
            this.showEaDialog = true;
			const singleData = {
			  userid: row.userid,
			  bankids: res.filter(item => item.isCheck).map(item => item.value)
			};
			this.eaDialog.setEditData({
			  singleData,
			  queBanks: res
			});
          });
    }
  }
};
</script>

<style scoped></style>
